package com.yuanheng100.ems4j.mapper;

import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.jdbc.SQL;

/**
 * Created by jlqian on 2017/1/11.
 */
public class Ems4jDepartmentSQLProvider
{
    public String selectByParentidAndDeptype(@Param("parentid") final int parentId, @Param("deptype") final short deptype)
    {
        return new SQL()
        {{
            SELECT("*");
            FROM("ems4j_department");
            WHERE("parentid = #{parentid,jdbcType=INTEGER}");
            if (deptype != 0)
            {
                WHERE("deptype = #{deptype,jdbcType=SMALLINT}");
            }
        }}.toString();
    }
}
